﻿<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="ClientesWF.aspx.cs" Inherits="ClientesWF" Title="Página sin título" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">

    <script type="text/javascript">


        function validaCuit(obj, args) {

            cuit = args.Value;
            if (typeof (cuit) == 'undefined')
            {
                args.IsValid = true;
                return true;
                 }
            cuit = cuit.toString().replace(/[-_]/g, "");
            if (cuit == '')
            {
                args.IsValid =  true;
                return true; //No estamos validando si el campo esta vacio, eso queda para el "required"   
                 }
            if (cuit.length != 11)
            {
                args.IsValid = false;
                return false;
                 }
            else {
                var mult = [5, 4, 3, 2, 7, 6, 5, 4, 3, 2];
                var total = 0;
                for (var i = 0; i < mult.length; i++) {
                    total += parseInt(cuit[i]) * mult[i];
                }
                var mod = total % 11;
                var digito = mod == 0 ? 0 : mod == 1 ? 9 : 11 - mod;
            }
            args.IsValid = ( digito == parseInt(cuit[10])  );
        }  


    </script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <p>
    Clientes</p>
<table class="style1">
    <tr>
        <td>
            Nombre:</td>
        <td colspan="2">
            <asp:TextBox ID="txtNombre" runat="server" MaxLength="40"></asp:TextBox>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                ControlToValidate="txtNombre" ErrorMessage="El nombre es obligatorio">*</asp:RequiredFieldValidator>
        </td>
    </tr>
    <tr>
        <td>
            Cuit:</td>
        <td colspan="2">
            <asp:TextBox ID="txtCuit" runat="server" MaxLength="11"></asp:TextBox>
            <asp:CustomValidator ID="cvCuit" runat="server" 
                ClientValidationFunction="validaCuit" ControlToValidate="txtCuit" 
                ErrorMessage="cuit mal formato" onservervalidate="cvCuit_ServerValidate"></asp:CustomValidator>
        </td>
    </tr>
    <tr>
        <td>
            Credito Maximo:</td>
        <td colspan="2">
            <asp:TextBox ID="txtCreditoMaximo" runat="server"></asp:TextBox>
            <asp:CompareValidator ID="CompareValidator1" runat="server" 
                ControlToValidate="txtCreditoMaximo" Display="Dynamic" 
                ErrorMessage="Ingrese solo numeros" Operator="DataTypeCheck" Type="Double"></asp:CompareValidator>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                ControlToValidate="txtCreditoMaximo" ErrorMessage="el credito es obligatorio"></asp:RequiredFieldValidator>
        </td>
    </tr>
    <tr>
        <td>
            Fecha Ingreso:</td>
        <td colspan="2">
            <asp:TextBox ID="txtIngreso" runat="server"></asp:TextBox>
            <asp:CompareValidator ID="cvIngreso" runat="server" 
                ControlToValidate="txtIngreso" ErrorMessage="Ingrese una fecha dd/mm/yyyy" 
                Operator="GreaterThanEqual" Type="Date" ValueToCompare="01/01/2000"></asp:CompareValidator>
        </td>
    </tr>
    <tr>
        <td>
            Provincia:</td>
        <td colspan="2">
            <asp:DropDownList ID="ddlProvincias" runat="server">
            </asp:DropDownList>
        </td>
    </tr>
    <tr>
        <td>
            Estado Civil</td>
        <td colspan="2">
            <asp:RadioButtonList ID="radEstadoCivil" runat="server">
            </asp:RadioButtonList>
        </td>
    </tr>
    <tr>
        <td>
            &nbsp;</td>
        <td colspan="2">
            &nbsp;</td>
    </tr>
    <tr>
        <td>
            &nbsp;</td>
        <td colspan="2">
            &nbsp;</td>
    </tr>
    <tr>
        <td>
            &nbsp;</td>
        <td colspan="2">
            &nbsp;</td>
    </tr>
    <tr>
        <td>
            &nbsp;</td>
        <td colspan="2">
            &nbsp;</td>
    </tr>
    <tr>
        <td>
            &nbsp;</td>
        <td colspan="2">
            &nbsp;</td>
    </tr>
    <tr>
        <td>
            &nbsp;</td>
        <td colspan="2">
            &nbsp;</td>
    </tr>
    <tr>
        <td>
            &nbsp;</td>
        <td colspan="2">
            &nbsp;</td>
    </tr>
    <tr>
        <td>
            &nbsp;</td>
        <td colspan="2">
            &nbsp;</td>
    </tr>
    <tr>
        <td>
            Fecha Egreso:</td>
        <td colspan="2">
            <asp:TextBox ID="txtEgreso" runat="server"></asp:TextBox>
            <asp:CompareValidator ID="CompareValidator3" runat="server" 
                ControlToCompare="txtIngreso" ControlToValidate="txtEgreso" 
                ErrorMessage="Fecha valida y mayor que ingreso" Operator="GreaterThanEqual" 
                Type="Date"></asp:CompareValidator>
            <asp:CustomValidator ID="CustomValidator1" runat="server" 
                ErrorMessage="CustomValidator" 
                onservervalidate="CustomValidator1_ServerValidate"></asp:CustomValidator>
        </td>
    </tr>
    <tr>
        <td>
            Edad:</td>
        <td colspan="2">
            <asp:TextBox ID="txtEdad" runat="server" MaxLength="3"></asp:TextBox>
            <asp:RangeValidator ID="RangeValidator1" runat="server" 
                ControlToValidate="txtEdad" ErrorMessage="La edad es valida entre 18 y 120" 
                MaximumValue="120" MinimumValue="18" Type="Integer"></asp:RangeValidator>
        </td>
    </tr>
    <tr>
        <td>
            Mail:</td>
        <td colspan="2">
            <asp:TextBox ID="txtMail" runat="server"></asp:TextBox>
            <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
                ControlToValidate="txtMail" ErrorMessage="mal formato del mail" 
                ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
        </td>
    </tr>
    <tr>
        <td>
            &nbsp;</td>
        <td colspan="2">
            &nbsp;</td>
    </tr>
    <tr>
        <td>
            &nbsp;</td>
        <td colspan="2">
            <asp:ValidationSummary ID="ValidationSummary1" runat="server" />
        </td>
    </tr>
    <tr>
        <td>
            &nbsp;</td>
        <td colspan="2">
            &nbsp;</td>
    </tr>
    <tr>
        <td>
            &nbsp;</td>
        <td colspan="2">
            <asp:Label ID="Label1" runat="server" ForeColor="#CC0000"></asp:Label>
        </td>
    </tr>
    <tr>
        <td>
            &nbsp;</td>
        <td>
            <asp:Button ID="butGrabar" runat="server" style="text-align: center" 
                Text="Grabar" onclick="butGrabar_Click" />
        </td>
        <td>
            <asp:Button ID="butCancelar" runat="server" Text="Cancelar" 
                onclick="butCancelar_Click" CausesValidation="False" />
        </td>
    </tr>
</table>
</asp:Content>

